<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>订单列表</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript">
        function sub() {
            //提交表单
            var byId = document.getElementById("form");
            byId.submit();
            // document.forms[0].submit();
        }
    </script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="list-group" class="col-md-12 column">
                <a href="#" class="list-group-item active">配送订单</a>
            </div>
<div>
    <div class="panel panel-warning" >
        <div class="panel-heading">
            <h3 class="panel-title">
                筛选查询
            </h3>
        </div>
        <div class="panel-body">
    <form method="get" action="/findOrders">
        <table>
            <tr><td>
       订单编号： <input type="text" name="ordernum" value="${ordernum!''}" size="8" />&nbsp;
       订单来源：<input type="text" value="${source!''}" name="source" size="8" />&nbsp;
       客户名称：<input name="username" value="${username!''}" type="text" size="8"  />
       订单时间：<input type="date" value="${orderdate!''}" name="orderdate"   />
       订单状态：<select name="state" >
<#--            //0未支付,1未发货,2已发货,3已完成,4已取消-->
            <#if (!state??)>
                <option value="0" >全部</option>
                <option value="1" >未支付</option>
                <option value="2" >未发货</option>
                <option value="3" >已发货</option>
                <option value="4" >已完成</option>
                <option value="5" >已取消</option>
            </#if>
            <#if (state??)>
            <option value="0" <#if (state==0)>selected="selected"</#if>>全部</option>
            <option value="1" <#if (state==1)>selected="selected"</#if>>未支付</option>
            <option value="2" <#if (state==2)>selected="selected"</#if>>未发货</option>
            <option value="3" <#if (state==3)>selected="selected"</#if>>已发货</option>
            <option value="4" <#if (state==4)>selected="selected"</#if>>已完成</option>
            <option value="5" <#if (state==5)>selected="selected"</#if>>已取消</option>
            </#if>
        </select>
        <input type="submit" value="查找"/>
                </td></tr>
        </table>
    </form></div></div>

                <div class="panel panel-default">
                    <div class="panel-heading">

                        <h3 class="panel-title">
                            数据列表
                            <button type="button" onclick="sub()" value="导出" style="float: right">导出订单</button>
                        </h3>
                    </div>
                    <#if (pageInfo.list?size!=0)>
                    <div class="panel-body">

                        <form action="/order/exportorder" method="post" id="form">
                            <table border="1" cellspacing="0">
                                <tr>
                                    <th>序号</th>
<#--                                    <th hidden="hidden">id</th>-->
                                    <th>订单编号</th>
                                    <th>商品名称</th>
                                    <th>单价</th>
                                    <th>数量</th>
                                    <th>客户编码</th>
                                    <th>客户名称</th>
                                    <th>联系方式</th>
                                    <th>实付金额</th>
                                    <th>订单时间</th>
                                    <th>订单来源</th>
                                    <th>订单形式</th>
                                    <th>订单状态</th>
                                    <th>送货员</th>
                                    <th>操作</th>
                                </tr>
                                <#list pageInfo.list as order>
                                    <tr>
                                        <td>${order_index+1}</td>
                                        <td hidden="hidden"><input name="orderids" value="${order.orderid}" type="text"/></td>
                                        <td>${order.ordernum}</td>
                                        <td>${order.commodity.commName}</td>
                                        <td>${order.commodity.price}</td>
                                        <td>${order.num}</td>
                                        <td>${order.client.clientnum}</td>
                                        <td>${order.client.username}</td>
                                        <td>${order.client.phone}</td>
                                        <td>${order.amountpaid}</td>
                                        <td>${order.orderdate?date}</td>
                                        <td>${order.source}</td>
                                        <td>${order.shape}</td>
                                        <td><#if (order.orderstate==1)>未支付</#if>
                                            <#if (order.orderstate==2)>未发货</#if>
                                            <#if (order.orderstate==3)>已发货</#if>
                                            <#if (order.orderstate==4)>已完成</#if>
                                            <#if (order.orderstate==5)>已取消</#if></td>
                                        <td><#if (order.deliveryman!="0")>${order.deliveryman!''}</#if></td>
                                        <td>
                                        <#if (order.orderstate==2 && order.shape=="配送订单")>
                                            <#if (empl.role.rName=="派单经理"&& order.deliveryman=="0")>
                                            <a href="/order/finddelivery?orderid=${order.orderid}">派单</a>
                                            </#if>
                                            <#if (order.deliveryman?last_index_of(empl.eName)==0 )>
                                                <a href="/order/sendgoods?orderid=${order.orderid}">发货</a>
                                            </#if>
                                            </#if>
                                            <a href="/order/findone?orderid=${order.orderid}">查看</a>
                                        </td>
                                    </tr>
                                </#list>
                                <tr>
                                    <td colspan="7" style="text-align: center">
                                        <#--                    ordernum, String source, String orderdate, String username,-->
                                        <#if (pageindex??)>
                                            <#if (pageindex>1)>
                                                <a href="/findOrders?pageindex=1&ordernum=${ordernum!''}&source=${source!''}&orderdate=${orderdate!''}&username=${username!''}&state=${state!''}">首页</a>
                                                &nbsp;&nbsp;&nbsp;
                                                <a href="/findOrders?pageindex=${pageInfo.prePage}&ordernum=${ordernum!''}&source=${source!''}&orderdate=${orderdate!''}&username=${username!''}&state=${state!''}">上一页</a>
                                            </#if>
                                        </#if>
                                        &nbsp;&nbsp;&nbsp;
                                        <#if (pageindex??)>
                                            <#if (pageindex<pages)>
                                                <a href="/findOrders?pageindex=${pageInfo.nextPage}&ordernum=${ordernum!''}&source=${source!''}&orderdate=${orderdate!''}&username=${username!''}&state=${state!''}">下一页</a>
                                                &nbsp;&nbsp;&nbsp;
                                                <a href="/findOrders?pageindex=${pageInfo.pages}&ordernum=${ordernum!''}&source=${source!''}&orderdate=${orderdate!''}&username=${username!''}">尾页</a>
                                            </#if>
                                        </#if>
                                    </td>
                                    <td colspan="8" style="text-align: center">
                                        当前${pageInfo.pageNum} / ${pageInfo.pages}页 每页${pageInfo.pageSize}条
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <#else ><h1>抱歉暂无数据!</h1>
                    </#if>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>